package zuoye9;

public class Test2 {
    public static void main(String[] args) {

        String maxString = "woaijavawozhenaijavawozhendeaijavawozhendehenaijavaxinbuxinwoaijavagun";

        String minString = "java";

        int count = getCount(maxString, minString);
        System.out.println("Java在大串中出现了：" + count + "次");
    }

    public static int getCount(String maxString, String minString) {

        int count = 0;
        int index;
        while((index=maxString.indexOf(minString))!=-1){
            count++;
            maxString = maxString.substring(index + minString.length());
        }
        return count;
    }
}
